'''
@Author: your name
@Date: 2020-05-18 00:45:15
@LastEditTime: 2020-05-18 01:01:13
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \Gitee\作业\5-15_作业\Gelonghui\framework\app_engine.py
'''
from appium import webdriver
from framework.logger import MyLog

# 实例化日志
log = MyLog.get_log()
logger = log.getlog()


class OpenApp(object):

    def __init__(self, driver):
        self.driver = driver

    def open_app(self):
        desired_caps = {"platformName": "Android", 
                        "platformVersion": "5.1.1", 
                        "deviceName": "127.0.0.1:62001",
                        "appPackage": "com.gelonghui.glhapp",
                        'noReset':'True',
                        'automationName':'UiAutomator1', 
                        'noSign':'True',
                        "appActivity": "com.gelonghui.glhapp.components.mainpage.MainActivity"
                        }
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
        logger.info("打开app")
        driver = self.driver
        return driver

    def quit_app(self):
        logger.info("退出app")
        self.driver.quit()
